package com.shang.spring.aop.impl;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;

//把这个类声明为一个切面
@Aspect
@Component
public class LoggingAspect {

    //声明该方法是一个前置方法
    @Before("execution(public int com.shang.spring.aop.impl.AtithCalculator.add(int,int))")
    public void beforeMethod(JoinPoint joinPoint){
        String name = joinPoint.getSignature().getName();
        System.out.println(name + "   方法执行之前.....");
    }

    @After("execution(public int com.shang.spring.aop.impl.AtithCalculator.add(int,int))")
    public void afterMethod(JoinPoint joinPoint){
        String name = joinPoint.getSignature().getName();
        System.out.println(name + "   方法执行之后.....");
    }

}
